package com.hailiao.beidou.message.data.db.entity

import androidx.room.Embedded
import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.Relation
import com.hailiao.beidou.message.data.db.constant.SendStatus

/**
 * 对话框信息
 *
 * @Author: D10NG
 * @Time: 2021/12/29 16:14
 */
@Entity(tableName = "chat_table")
data class ChatEntity(
    // 号码
    @PrimaryKey
    var number: String = "",
    // 时间
    var time: Long = 0,
    // 未读消息个数
    var unreadCount: Int = 0,
    // 消息内容
    var content: String = "",
    // 草稿
    var draftContent: String = "",
    // 发送状态
    var sendStatus: Int = SendStatus.SUCCESS.value
)

/**
 * 对话框信息 + 联系人信息
 *
 * @Author: D10NG
 * @Time: 2021/12/29 16:36
 */
data class ChatWithContactEntity(
    @Embedded
    val chat: ChatEntity,

    @Relation(
        parentColumn = "number",
        entityColumn = "number"
    )
    val contact: ContactEntity?
)
